<template>
  <el-dialog title="选择方案类型" :visible.sync="$attrs.visableIf" @close="handleCloseDialog" :close-on-click-modal="false" :close-on-press-escape="false" append-to-body width="700px">
    <el-form ref="form" :rules="rules" :model="form" label-width="120px" label-position="top">
      <el-form-item prop="id">
        <el-radio-group v-model="form.id" class="advertType">
          <el-radio v-for="(item,index) in advertTypeList"  :key="index" :label="Number(item.value)">
            <div class="title">{{ item.label }}</div>
            <div class="content" >{{item.tips}}</div>
            <div class="img" :class="index==1?`orange`:`green`"><img :src="item.icon" /></div>
          </el-radio>
        </el-radio-group>
      </el-form-item>

    </el-form>
    <div class="footer-btn" slot="footer">
      <el-button type="primary" @click="handleCloseDialog">取消</el-button>
      <el-button @click="onSubmit('form')">提交</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: 'selectProgrammeType',
  components: {},
  data() {
    return {
      form: {
        id: '',//标签名称
      },
      advertTypeList: [
        {
          value: 1,
          label: '默认方案',
          tips: '给不发送“按条件触发的方案”的客户发送默认方案，每个企微号只能启用一个默认方案',
          icon: require('../../../assets/images/y-icon1.png'),
        },
        {
          value: 2,
          label: '按条件触发方案',
          tips: `根据新客户的条件触发相应的运营方案，建议配合【渠道活码】使用，给不同来源的客户打上相应的标签，若触发了多个方案，会同时执行这些方案`,
          icon: require('../../../assets/images/y-icon2.png'),
        }
      ],
      rules: {
        'id': [
          {required: true, message: '请输入标签组名称', trigger: 'change'}
        ],

      },
    }
  },
  created() {
  },
  mounted() {
  },
  watch: {},
  methods: {
    onSubmit(formName) {
      //提交的代码
      this.$refs[formName].validate((valid) => {
        if (valid) {
          console.log('提交表单');
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    handleCloseDialog() {
      this.$emit('update:visableIf', false);
      this.$emit('handleQuery');
    }
  }
}
</script>

<style scoped lang="scss">
.footer-btn {
  display: flex;
  justify-content: flex-end;
}

.item-li {
  padding: 16px;
  background: #f7f7f7;
  border-radius: 2px;

  .el-radio-group {
    margin-bottom: 10px;
  }
}

::v-deep .el-dialog__body {
  overflow-y: auto;
  min-height: 300px;
  max-height: 600px;

  .el-form-item {
    border: none !important;

    .el-form-item__label {
      padding-bottom: 0px
    }

    .item-big {
      display: flex;

      .el-button--medium {
        padding: 0px 10px;
        margin-left: 20px;
      }
    }
  }
}
.el-radio-group {
  .el-radio {
    display:flex;
    border:1px solid #eee;
    padding:15px;
    margin-bottom:15px;
    width:100%;
    ::v-deep .el-radio__input {
      margin-top: 13px;
    }
    ::v-deep  .el-radio__label {
      display: flex;
      padding-right:120px;
      position: relative;
      flex-direction: column;
      .title {
        height: 40px;
        display: flex;
        align-items: center;
        font-size: 16px;
        font-weight: 600;
        color: rgba(0, 0, 0, .85);
        margin-left: 10px;
      }
      .content {
        margin-top: 8px;
        color: rgba(0, 0, 0, .45);
        white-space: normal;
        line-height: 25px;
      }
      .img {
        position: absolute;
        right: 10px;
        top: 0px;
        width: 80px;
        height: 80px;
        border-radius: 8px;
        align-items: center;
        justify-content: center;
        display: flex;
        img {
          width: 40px;
          height: 40px;
        }
        &.orange {
          background:#ffede3;
        }
       &.green {
          background:#ebf2ff;
        }
      }
    }
  }

}
</style>
